package com.maycurobj.repository.bpm;


import com.maycurobj.entity.bpm.SalePlanOPDCADTO;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;


@Repository
public interface SalePlanOPDCAMapper extends JpaRepository<SalePlanOPDCADTO, String> {
    /**
     * bpm用户id转换为工号
     * @param id
     * @return
     */
    @Query(nativeQuery = true, value= "select id,id as objId, new_account_name,sequenceNo as formCode,sequenceNo as newFormCode,empNo,planAmount,fromCityId,toCityId,`subject`,new_work_summary,planType,new_date_start,new_date,start_time,stop_time as end_time,business_trip_days,tripType,sendUrl as url,new_work_plan,participants from i5zdm_saleplan_opdca where id=:id")
    SalePlanOPDCADTO getEntity(@Param(value = "id") String id);

    /**
     * 通过sequenceNo 找记录
     * @param sequenceNo
     * @return
     */
    @Query(nativeQuery = true, value= "select id,id as objId, new_account_name,sequenceNo as formCode,sequenceNo as newFormCode,empNo,planAmount,fromCityId,toCityId,`subject`,new_work_summary,planType,new_date_start,new_date,start_time,stop_time as end_time,business_trip_days,tripType,sendUrl as url,new_work_plan,participants from i5zdm_saleplan_opdca where sequenceNo=:sequenceNo")
    SalePlanOPDCADTO getEntityBySeqNo(@Param(value = "sequenceNo") String sequenceNo);


    @Query(nativeQuery = true, value= "select cityFullCode from iak8a_maycurcitydb where id=:id")
    String getToCityId(@Param(value = "id") String id);
}
